using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_Test_Question
    {
        public static bool Insert(Object tmp)
        {
            TEST_QUESTION obj = (TEST_QUESTION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@TEST_QUESTION_DESC", obj.TEST_QUESTION_DESC));
            _list.Add(new SqlParameter("@TEST_QUESTION_ID", obj.TEST_QUESTION_ID));
            _list.Add(new SqlParameter("@TEST_QUESTION_LEVEL", obj.TEST_QUESTION_LEVEL));
            _list.Add(new SqlParameter("@TEST_QUESTION_SCORE", obj.TEST_QUESTION_SCORE));
            _list.Add(new SqlParameter("@TEST_QUESTION_TYPE", obj.TEST_QUESTION_TYPE));
            _list.Add(new SqlParameter("@TEST_SECTION_ID", obj.TEST_SECTION_ID));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));
            

            int n = clsDataAccessHelper.ExecNonQuery("sp_test_question_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            TEST_QUESTION obj = (TEST_QUESTION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@TEST_QUESTION_DESC", obj.TEST_QUESTION_DESC));
            _list.Add(new SqlParameter("@TEST_QUESTION_ID", obj.TEST_QUESTION_ID));
            _list.Add(new SqlParameter("@TEST_QUESTION_LEVEL", obj.TEST_QUESTION_LEVEL));
            _list.Add(new SqlParameter("@TEST_QUESTION_SCORE", obj.TEST_QUESTION_SCORE));
            _list.Add(new SqlParameter("@TEST_QUESTION_TYPE", obj.TEST_QUESTION_TYPE));
            _list.Add(new SqlParameter("@TEST_SECTION_ID", obj.TEST_SECTION_ID));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));
            
            int n = clsDataAccessHelper.ExecNonQuery("sp_test_question_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            TEST_QUESTION obj = (TEST_QUESTION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@TEST_QUESTION_DESC", obj.TEST_QUESTION_DESC));
            _list.Add(new SqlParameter("@TEST_QUESTION_ID", obj.TEST_QUESTION_ID));
            _list.Add(new SqlParameter("@TEST_QUESTION_LEVEL", obj.TEST_QUESTION_LEVEL));
            _list.Add(new SqlParameter("@TEST_QUESTION_SCORE", obj.TEST_QUESTION_SCORE));
            _list.Add(new SqlParameter("@TEST_QUESTION_TYPE", obj.TEST_QUESTION_TYPE));
            _list.Add(new SqlParameter("@TEST_SECTION_ID", obj.TEST_SECTION_ID));
            _list.Add(new SqlParameter("@USER_ID", obj.USER_ID));
            
            int n = clsDataAccessHelper.ExecNonQuery("sp_test_question_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<TEST_QUESTION> LoadAll()
        {
            List<TEST_QUESTION> _list = new List<TEST_QUESTION>();
            //call stored getlist here
            return _list;
        }
    }
}
